//
//  WCNPICCRecordVC.m
//  WCN
//
//  Created by wsj2015 on 16/3/28.
//  Copyright © 2016年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WCNPICCRecordVC.h"
#import "WCButton.h"
#import "WCNPatientAddVC.h"

@interface WCNPICCRecordVC ()

@end

@implementation WCNPICCRecordVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self configNav];
}
- (void)configNav{
    self.navigationItem.titleView = [self titleView];
    WCButton *addRecordBtn = [WCButton wcButtonWithType:WCButtonTypeAdd];
    addRecordBtn.frame = CGRectMake(40, 0, 40, 30);
    [addRecordBtn addTarget:self action:@selector(addRecordBtn:) forControlEvents:UIControlEventTouchUpInside];
}
// 标题视图
- (UIView *)titleView
{
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 8, 14, 14)];
    imageView.translatesAutoresizingMaskIntoConstraints = NO;
    imageView.image = [UIImage imageNamed:@"Patient_Title"];
    
    UILabel *titleLabel = [[UILabel alloc] init];
    
    titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
    titleLabel.font = [UIFont boldSystemFontOfSize:20];
    
    UIView *view = [[UIView alloc] init];
    view.translatesAutoresizingMaskIntoConstraints = NO;
    [view addSubview:imageView];
    [view addSubview:titleLabel];
    [view addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeHeight
                                                     relatedBy:NSLayoutRelationEqual
                                                        toItem:nil attribute:NSLayoutAttributeNotAnAttribute
                                                    multiplier:1 constant:30]];
    [view addConstraint:[NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeLeading
                                                     relatedBy:NSLayoutRelationEqual
                                                        toItem:view attribute:NSLayoutAttributeLeading
                                                    multiplier:1 constant:0]];
    [view addConstraint:[NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeTrailing
                                                     relatedBy:NSLayoutRelationEqual
                                                        toItem:view attribute:NSLayoutAttributeTrailing
                                                    multiplier:1 constant:0]];
    [view addConstraint:[NSLayoutConstraint constraintWithItem:imageView attribute:NSLayoutAttributeCenterY
                                                     relatedBy:NSLayoutRelationEqual
                                                        toItem:view attribute:NSLayoutAttributeCenterY
                                                    multiplier:1 constant:0]];
    [view addConstraint:[NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeCenterY
                                                     relatedBy:NSLayoutRelationEqual
                                                        toItem:imageView attribute:NSLayoutAttributeCenterY
                                                    multiplier:1 constant:0]];
    [view addConstraint:[NSLayoutConstraint constraintWithItem:titleLabel attribute:NSLayoutAttributeLeading
                                                     relatedBy:NSLayoutRelationEqual
                                                        toItem:imageView attribute:NSLayoutAttributeTrailing
                                                    multiplier:1 constant:0]];
    
    UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 118, 30)];
    [titleView addSubview:view];
    [titleView addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeCenterX
                                                          relatedBy:NSLayoutRelationEqual
                                                             toItem:titleView attribute:NSLayoutAttributeCenterX
                                                         multiplier:1 constant:0]];
    [titleView addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeCenterY
                                                          relatedBy:NSLayoutRelationEqual
                                                             toItem:titleView attribute:NSLayoutAttributeCenterY
                                                         multiplier:1 constant:0]];
    
    UIButton *showPatientDetail = [[UIButton alloc] initWithFrame:titleView.bounds];
    [showPatientDetail addTarget:self action:@selector(showPatientDetail) forControlEvents:UIControlEventTouchUpInside];
    [titleView addSubview:showPatientDetail];
    
    return titleView;
}
- (void)showPatientDetail
{
    WCNPatientAddVC *vc = [[WCNPatientAddVC alloc] initWithPatient:self.patient];
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
